var domTop = 0;

window.addEventListener('scroll', function (e) {
    var oTop = document.body.scrollTop==0?document.documentElement.scrollTop:document.body.scrollTop;
    document.getElementById('textContent').innerHTML = oTop;
    domTop = oTop;
})

const setScrollTop = (top = 0) => {
    if(document.body.scrollTop === 0) {
        document.documentElement.scrollTop = top;
    } else {
        document.body.scrollTop = top;
    }
}

const blurHandler = (e) => {
    setScrollTop();
}

const focusHandler = (e) => {
    setScrollTop(domTop);
}

document.getElementById('curInput').addEventListener('blur', blurHandler)
document.getElementById('curInput2').addEventListener('blur', blurHandler);

document.getElementById('curInput').addEventListener('focus', focusHandler)
document.getElementById('curInput2').addEventListener('focus', focusHandler);

// document.getElementById('reset').addEventListener('click', function () {
//     if(document.body.scrollTop === 0) {
//         document.documentElement.scrollTop = 0;
//     } else {
//         document.body.scrollTop = 0;
//     }
// })